import axios from "axios"
import { Dialog } from "vant";
import store from "../store";
import router from "../router";
const request = axios.create({
	baseURL:"https://marketing.aliyunhg.com/",
	timeout:6000,
	method:"POST"
})

request.interceptors.response.use((response)=>{
  const code = response.data.status
  console.log(response.data)
  if (code!==200){
    if (code===501){
      Dialog({
        message: response.data.data,
      })
    }
    if (code===520){
      Dialog.alert({
        title: '提示',
        message: '账号过期，请重新登录！！！',
      }).then(async () => {
        await store.dispatch('logout')
        await router.push('/')
      });
    }
    return  Promise.reject(false)
  }else {
    return response
  }
})

export default request
